<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    .red {
        background: red;
        width: 200px;
        height: 200px;
    }
    /* .red::after {
        content: "";
        background: yellowgreen;
        width: 50px;
        height: 50px;
        display: block;
    }
    .red::before {
        content: "";
        background: blue;
        width: 50px;
        height: 50px;
        display: block;
    } */
</style>
<body>
    <div class="red" style="position: absolute;left: 0;"></div>
</body>
<script>
    function getStyle(elem,prop){
        if(window.getComputedStyle){
            return window.getComputedStyle(elem,null)[prop];
        }else {
            return elem.currentStyle[prop];
        }
    }
    var div = document.getElementsByTagName('div')[0];
    setInterval(()=>{
        div.style.left = parseInt(getStyle(div,'left'))  + 10 + 'px';
    },500)
</script>
</html>